package com.mryan.auth.controller;

import com.mryan.auth.pojo.Message;
import com.mryan.auth.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @description： LoginController
 * @Author MRyan
 * @Date 2021/6/14 9:31
 * @Version 1.0
 */
@Controller
@RequestMapping(value = "/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 登录，成功返回用户信息
     *
     * @param accountId
     * @param accountPassword
     * @return
     */
    @RequestMapping(value = "")
    @ResponseBody
    public Message loginByName(@RequestParam("accountName") String accountName,
                               @RequestParam("accountPassword") String accountPassword) {
        return loginService.checkPassword(accountName, accountPassword);
    }

    /**
     * 获取用户信息
     *
     * @param accountId
     * @return
     */
    @RequestMapping(value = "getUser")
    @ResponseBody
    public Message getUserInfo(@RequestParam("accountId") Long accountId) {
        return loginService.getAccountInfo(accountId);
    }

}
